home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
samples
/
Hector1600
/
UnsignedDiv.asm
< prev
next >
Wrap
Assembly Source File
|
1995-07-26
|
2KB
|
80 lines
;
; ECE463 Unsigned Division
;
; Coded by: Bradford W. Mott
; September 8,1993
;
.org 0000
move #512,sp
move #0,r0 ; Init Loop Variable
loop: cmp #num_els,r0 ; Check to see if we're finished
bra finished,.eq
move r0,r1
add r1,r1
move [r1,data1],r7 ; Get the dividend
move [r1,data1+1],r8
move [r0,data2],r9 ; Get the divisor
jsr divide ; divide the two numbers
move r10,[r1,result]
move r11,[r1,result+1]
inc r0
bra loop
finished: stop
divide: clr r10 ; quot
move #16,r13 ; Init the counter
dloop: clc
rol r10 ; quot := Bshl(quot,0,C)
clc
rol r8 ; loDvnd := Bshl(loDvnd,0,C)
rol r7 ; hiDvnd := Bshl(hiDvnd,C,C)
move #0,r12
bra no_flag,.cc
move #1,r12
no_flag: sec
not r9
addc r9,r7 ; hiDvnd := Badd(hiDvnd,Bcom(dvsr),1,C)
bra no_flag2,.cc
move #1,r12
no_flag2: not r9
cmp #1,r12
bra set_bit,.eq
clc
addc r9,r7 ; hiDvnd := Badd(hiDvnd,dvsr,0,C)
bra next
set_bit: or #1,r10
next: dec r13
bra dloop,.ne
move r7,r11
rts ; That's All
.org 256
num_els: .equ 3
data1: .word 0x0000,0x0064,0x0000,0x00FF,0x00FF,0xFFFF
data2: .word 0x000A, 0x000F, 0x0F00
result: .rmw num_els+num_els